const path = require('path');

// resolve 拼接规范的绝对路径 会根据系统分隔符对路径中的分隔符进行转换
const indexPath = path.resolve(__dirname, './a/index.html');

console.log('------------indexPath--------------');
console.log(indexPath);
console.log('------------indexPath--------------');

// sep 系统分隔符 win \      linux /
console.log('------------sep 系统分隔符--------------');
console.log(path.sep);
console.log('------------sep 系统分隔符--------------');

// parse 方法 解析路径并返回路径对象
// root 根目录
// dir 文件目录绝对路径
// base 完整文件名（带后缀名）
// ext 文件后缀名
// name 文件名（不带后缀名）
console.log('------------parse--------------');
console.log(path.parse(indexPath));
console.log('------------parse--------------');

// basename 获取路径的基础名称

console.log('------------basename--------------');
console.log(indexPath);
console.log(path.basename(indexPath));
console.log(path.basename(indexPath.replace(path.basename(indexPath), '')));
console.log('------------basename--------------');

// dirname 获取路径的目录名

console.log('------------dirname--------------');
console.log(indexPath);
console.log(path.dirname(indexPath));
console.log(path.dirname(indexPath.replace(path.basename(indexPath), '')));
console.log('------------dirname--------------');

// extname 获取路径中的扩展名

console.log('------------extname--------------');
console.log(indexPath);
console.log(path.extname(indexPath));
console.log(path.extname(indexPath.replace(path.basename(indexPath), '')));
console.log('------------extname--------------');